package sumbytype;

import java.io.IOException;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

public class SortReducer extends Reducer<CompositeKey, IntWritable, Text, IntWritable> {
    
    
    
    public void reduce(CompositeKey key, Iterable<IntWritable> values, Context context) 
            throws IOException, InterruptedException {
        
        int sum = 0;
        for (IntWritable val: values) {
            sum += val.get();
        }
        
        context.write(new Text(key.toString()), new IntWritable(sum));
        
    } 
    
}
